# 用户路由
from app.api import api_bp
from app.api.controllers.user_controller import UserController


@api_bp.route('/users', methods=['GET'])
def get_users():
    """获取所有用户"""
    return UserController.get_all_users()


@api_bp.route('/users/<int:user_id>', methods=['GET'])
def get_user(user_id):
    """获取单个用户"""
    return UserController.get_user_by_id(user_id)


@api_bp.route('/user', methods=['GET'])
def get_user_by_params():
    """通过查询参数获取单个用户"""
    return UserController.get_user_by_params()


@api_bp.route('/users', methods=['POST'])
def create_user():
    """创建新用户"""
    return UserController.create_user()


@api_bp.route('/users/<int:user_id>', methods=['PUT'])
def update_user(user_id):
    """更新用户信息"""
    return UserController.update_user(user_id)


@api_bp.route('/users/<int:user_id>', methods=['DELETE'])
def delete_user(user_id):
    """删除用户"""
    return UserController.delete_user(user_id)